<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title></title>
    <meta name="renderer" content="webkit|ie-comp|ie-stand">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <meta http-equiv="Expires" CONTENT="0">
    <meta http-equiv="Cache-Control" content="no-siteapp,no-transform,no-store, no-cache, must-revalidate">
    <meta http-equiv="Pragma" content="no-cache">
    <link rel="shortcut icon" href="./../../../favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./../../../static/css/font.css">
    <link rel="stylesheet" href="./../../../static/css/weadmin.css">
    <script type="text/javascript" src="/lib/layui/layui.js" charset="utf-8"></script>
    <link rel="stylesheet" href="../../../static/css/buildUnit/common.css">
    <script type="text/javascript" src="/lib/mxDraw/mxcustom.js"></script>
    <style>
        body {
            padding: 0;
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
        }

        #content {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            position: absolute;
            top: 30px;
            bottom: 10px;
            left: 0;
            right: 0;
            width: 100%;
        }

        .dwgBox {
            width: 49%;
            height: 100%;
            float: left;
        }

        .dwgBox > object {
            width: 100%;
        }
    </style>
</head>
<body>
<div style="height:30px;">
    <input type="button" class="layui-btn" id="compare" value="全图比较"/>
</div>
<div id="content">
    <div class="dwgBox">
        <object classid="clsid:74A777F8-7A8F-4e7c-AF47-7074828086E2" id="ESHENBAO1" width="100%" height="100%">
            <param name="_Version" value="65536">
            <param name="_ExtentX" value="24289">
            <param name="_ExtentY" value="14552">
            <param name="_StockProps" value="0">
            <param name="DwgFilePath" value="">
            <param name="IsRuningAtIE" value="1">
            <param name="EnablePrintCmd" value="1">
            <param name="ShowCommandWindow" value="1">
            <param name="ShowToolBars" value="0">
            <param name="ShowModelBar" value="1">
            <param name="Iniset" value="">
            <param name="ToolBarFiles" value="">
            <param name="ShowMenuBar" value="0">
            <param name="EnableUndo" value="1">
            <param name="ShowPropertyWindow" value="0">
            <param name="EnableClipboard" value="0">
            <param name="wmode" value="opaque">
            <param name="UserName" value="黑龙江霄岭工程设计咨询有限公司">
            <param name="UserSoftwareName" value="易审宝电子审图系统">
            <param name="UserPhone" value="0311-85299922">
            <param name="UserData"
                   value="HHHH2932B346CB4FB33268F82C067BD80C0998015277215224C6E03D9E26B44C1DDE3A149E372593928DE9D16CDE578C1AA78297000029325E9C61B7B1CC6382E90C654476367B157DC5F29C637EA5C0ABDD875AC6A8641859605577D0E5DBAAB4BDD00A3504745D00002932F2FCFB6D4737D0840367E365C6518B6AB36B3F5E8F97F3C2E2F784EDD76E22A7642259B26A325C32A44F19363C19BC7C000029320E1C775537C23684FA6AED6027262405D47230453973DCA15A9D8190AB7ACE6B0FADA2728233C4C1CDF7B6E931266615000029321F65F234DC44D3CD9422C3B0DD359E461DF5ED796E727C150BC76B5C61357E5254989B7480C3C590CDF7B6E9312666150000293219A2B18559AC2D82E4B6E921160F76EA76917611C7E3B96752C2300545AAB3FF9A43C186C0C98730AEADBBB20DC6CA0F000029324E04BC3FD3A723657CDC9C62888C91DF7FB9C9A177255B9632C6339EBD2C16BCC0504FC31BB30BDE70560B5C15BC00AD00002932A1BDA66E3CB4288316732E736DC0EAF1CB7E7105573BD5B1556EEC7CEC8E5487846C55E2628B3C65A046261D3B0432EA000029322CB400329EAF07A9A7A1AA45A3F982B39C82353FF3E11E90F985F70F136A0C1D2C7E326C36589EC896523CEE7F0005F400002932E46B8D7EFEE2C37161EF8EB65B23A773B38AC09926301DFC3E21E48EF469306F35A3039C8828DDBF70560B5C15BC00AD0000060A1FB7E03F08E3EACD0000">
        </object>
    </div>
    <div class="dwgBox">
        <object classid="clsid:74A777F8-7A8F-4e7c-AF47-7074828086E2" id="ESHENBAO2" width="100%" height="100%">
            <param name="_Version" value="65536">
            <param name="_ExtentX" value="24289">
            <param name="_ExtentY" value="14552">
            <param name="_StockProps" value="0">
            <param name="DwgFilePath" value="">
            <param name="IsRuningAtIE" value="1">
            <param name="EnablePrintCmd" value="1">
            <param name="ShowCommandWindow" value="1">
            <param name="ShowToolBars" value="0">
            <param name="ShowModelBar" value="1">
            <param name="Iniset" value="">
            <param name="ToolBarFiles" value="">
            <param name="ShowMenuBar" value="0">
            <param name="EnableUndo" value="1">
            <param name="ShowPropertyWindow" value="0">
            <param name="EnableClipboard" value="0">
            <param name="wmode" value="opaque">
            <param name="UserName" value="黑龙江霄岭工程设计咨询有限公司">
            <param name="UserSoftwareName" value="易审宝电子审图系统">
            <param name="UserPhone" value="0311-85299922">
            <param name="UserData"
                   value="HHHH2932B346CB4FB33268F82C067BD80C0998015277215224C6E03D9E26B44C1DDE3A149E372593928DE9D16CDE578C1AA78297000029325E9C61B7B1CC6382E90C654476367B157DC5F29C637EA5C0ABDD875AC6A8641859605577D0E5DBAAB4BDD00A3504745D00002932F2FCFB6D4737D0840367E365C6518B6AB36B3F5E8F97F3C2E2F784EDD76E22A7642259B26A325C32A44F19363C19BC7C000029320E1C775537C23684FA6AED6027262405D47230453973DCA15A9D8190AB7ACE6B0FADA2728233C4C1CDF7B6E931266615000029321F65F234DC44D3CD9422C3B0DD359E461DF5ED796E727C150BC76B5C61357E5254989B7480C3C590CDF7B6E9312666150000293219A2B18559AC2D82E4B6E921160F76EA76917611C7E3B96752C2300545AAB3FF9A43C186C0C98730AEADBBB20DC6CA0F000029324E04BC3FD3A723657CDC9C62888C91DF7FB9C9A177255B9632C6339EBD2C16BCC0504FC31BB30BDE70560B5C15BC00AD00002932A1BDA66E3CB4288316732E736DC0EAF1CB7E7105573BD5B1556EEC7CEC8E5487846C55E2628B3C65A046261D3B0432EA000029322CB400329EAF07A9A7A1AA45A3F982B39C82353FF3E11E90F985F70F136A0C1D2C7E326C36589EC896523CEE7F0005F400002932E46B8D7EFEE2C37161EF8EB65B23A773B38AC09926301DFC3E21E48EF469306F35A3039C8828DDBF70560B5C15BC00AD0000060A1FB7E03F08E3EACD0000">
        </object>
    </div>
</div>
<script src="../../../static/js/main.js"></script>
<script>
    //例子图纸：http://61.55.140.248:8094/ysb_store_path/drawing/6e6fbe961ac84e768f8e2c76fe65520d/761364b59d4a4804b695d9d95103ea83/b084bdeed5854c1ba80ecd5e1113bb2f.dwg
    layui.use([
        'jquery',
        'configure',
        'sessionFun',
        'bluebird',
    ], function () {
        var $ = layui.jquery;
        var configure = layui.configure;
        var sessionFun = layui.sessionFun;
        //获取图纸对象
        var drawingData = sessionFun.get(configure.SESSION_DRAWING_DATA);

        var checkData = sessionFun.get(configure.SESSION_DRAWING_COMPARE_DATA);

        var dwg1 = checkData[0];
        var dwg2 = checkData[1];

        var mxtime1 = setTimeout(InitMxDrawX1, 900);
        var mxtime2 = setTimeout(InitMxDrawX2, 1100);
        var mxOcx1 = document.getElementById("ESHENBAO1");
        var mxOcx2 = document.getElementById("ESHENBAO2");

        function InitMxDrawX1() {
            if (mxOcx1) {
                if (!mxOcx1.IsIniting()) {
                    clearInterval(mxtime1);
                    // 控件初始化完成，需要在启动做的事，在这里做
                    var url1 = configure.DRAWING_HTTP + dwg1.realName;
                    // 启动时打开文件
                    var str = mxOcx1.Download(url1);
                    mxOcx1.OpenDwgFile(str);
                    // mxOcx1.ZommAll();
                    //....
                }
            }
        }

        function InitMxDrawX2() {
            if (mxOcx2) {
                if (!mxOcx2.IsIniting()) {
                    clearInterval(mxtime2);
                    // 控件初始化完成，需要在启动做的事，在这里做
                    // 启动时打开文件
                    var url2 = configure.DRAWING_HTTP + dwg2.realName;
                    var str = mxOcx2.Download(url2);
                    mxOcx2.OpenDwgFile(str);
                    // mxOcx2.ZommAll();
                    //....
                    var cssTime = setTimeout(function () {
                        clearTimeout(cssTime);
                        cssTime = null;
                        $('.dwgBox').css('width', '50%');
                    }, 500);

                }
            }
        }

        $('#compare').click(function(){
            document.getElementById("ESHENBAO1").DoCommand(1);
        });

        function DoCmd(iCmd) {
            document.getElementById("ESHENBAO1").DoCommand(iCmd);
        }

        function AllCompareDWG() {
            var ocx1 = document.getElementById("ESHENBAO1");
            var ocx2 = document.getElementById("ESHENBAO2");

            var database1 = ocx1.GetDatabase();
            var database2 = ocx2.GetDatabase();

            var filter = ocx1.NewResbuf();

            var compare1 = ocx1.NewComObject("IMxDrawCompare");
            compare1.Do(database1, database2, filter);
            var aryDifferent1 = compare1.GetCurveIdsOfTheDifferent();
            //compare1.DrawFlag(1.0,false);


            // 反过来比较一下，用来确定，那些对象是新增加的。
            var compare2 = ocx1.NewComObject("IMxDrawCompare");
            compare2.Do(database2, database1, filter);
            var aryDifferent2 = compare2.GetCurveIdsOfTheDifferent();
            //compare2.DrawFlag(1.0,true);

            var iErase = 0;
            var iModify = 0;
            var iAdd = 0;
            var i = 0;

            for (; i < aryDifferent1.Count; i++) {
                var lId = aryDifferent1.AtObjectId(i);
                if (compare1.GetIsErase(lId)) {
                    iErase = iErase + 1;
                }
                else {
                    iModify = iModify + 1;
                }
            }

            i = 0;
            for (; i < aryDifferent2.Count; i++) {
                var lId = aryDifferent2.AtObjectId(i);
                if (compare2.GetIsErase(lId)) {
                    iAdd = iAdd + 1;
                }
            }

            var modfColor = ocx1.NewComObject("IMxDrawModifyTheColor");
            modfColor.Do(ocx1.GetDatabase(), 3289650);
            modfColor.DoEntity(aryDifferent1, 255);

            var modfColor1 = ocx2.NewComObject("IMxDrawModifyTheColor");
            modfColor1.Do(ocx2.GetDatabase(), 3289650);
            modfColor1.DoEntity(aryDifferent2, 255);

            alert(iModify + "对象修改," + iErase + "对象删除," + iAdd + "对象被增加");

        }

        function BoundCompare() {

            var ocx1 = document.getElementById("ESHENBAO1");
            var ocx2 = document.getElementById("ESHENBAO2");
            var filter = ocx1.NewResbuf();
            var getPt = ocx1.NewComObject("IMxDrawUiPrPoint");

            getPt.message = "点取第一点";
            if (getPt.go() != 1)
                return;

            var frstPt = getPt.value();

            var getCorner = ocx1.NewUtility();


            var secondPt = getCorner.GetCorner(frstPt, "点取第二点:");
            if (secondPt == null)
                return;

            var points = ocx1.NewComObject("IMxDrawPoints");

            points.Add2(frstPt);
            points.Add2(secondPt);

            var filter = ocx1.NewResbuf();
            DoImpCompare(points, filter);

        }

        function DoImpCompare(points, filter) {

            var ocx1 = document.getElementById("ESHENBAO1");
            var ocx2 = document.getElementById("ESHENBAO2");

            var database1 = ocx1.GetDatabase();
            var database2 = ocx2.GetDatabase();

            var compare1 = ocx1.NewComObject("IMxDrawCompare");
            compare1.Bound = points;

            compare1.Do(database1, database2, filter);

            var aryDifferent1 = compare1.GetCurveIdsOfTheDifferent();

            // compare1.DrawFlag(1.0, false);


            // 反过来比较一下，用来确定，那些对象是新增加的。
            var compare2 = ocx1.NewComObject("IMxDrawCompare");
            compare2.Bound = points;
            compare2.Do(database2, database1, filter);

            var aryDifferent2 = compare2.GetCurveIdsOfTheDifferent();

            // compare2.DrawFlag(1.0, true);


            var iErase = 0;
            var iModify = 0;
            var iAdd = 0;
            var i = 0;

            for (; i < aryDifferent1.Count; i++) {
                var lId = aryDifferent1.AtObjectId(i);
                if (compare1.GetIsErase(lId)) {
                    iErase = iErase + 1;
                }
                else {
                    iModify = iModify + 1;
                }
            }

            i = 0;
            for (; i < aryDifferent2.Count; i++) {
                var lId = aryDifferent2.AtObjectId(i);
                if (compare2.GetIsErase(lId)) {
                    iAdd = iAdd + 1;
                }
            }

            alert(iModify + "对象修改," + iErase + "对象删除," + iAdd + "对象被增加");
        }

        function DoCommandEventFunc(iCmd) {
            if (iCmd == 1) {
                AllCompareDWG();
            } else if (iCmd == 20) {
                BoundCompare();
            }
        }

        document.getElementById("ESHENBAO1").ImplementCommandEventFun = DoCommandEventFunc;

    });

</script>
</body>
</html>